import React from 'react';
import {RouteProp, useNavigation} from '@react-navigation/native';
import {RootStackParamList} from '../../Nav/routes';
import PaymentCard from '../../UI/Payment/PaymentCard';
import {NativeStackNavigationProp} from '@react-navigation/native-stack';

type PaymentScreenRouteProp = RouteProp<RootStackParamList, 'Payment'>;

type Props = {
  route: PaymentScreenRouteProp;
};

export default function PaymentView({route}: Readonly<Props>) {
  const navigation =
    useNavigation<NativeStackNavigationProp<RootStackParamList>>();
  const {orderId} = route.params;
  return (
    <PaymentCard
      orderId={orderId}
      onReceipt={receipt => {
        navigation.replace('PaymentReceipt', {
          paymentReceipt: receipt,
        });
      }}></PaymentCard>
  );
}
